package com.dazzle.system.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.dazzle.core.util.query.QueryFilter;
import com.dazzle.system.entity.SysImages;
import com.dazzle.system.entity.SysUser;
import com.dazzle.system.service.SysImagesService;

import flexjson.JSONSerializer;

@Controller
@RequestMapping("/system")
public class SysImagesController{
	@Resource
	private SysImagesService sysImagesService;
	
	@RequestMapping("/images_list")
	public String list(HttpServletRequest request,HttpServletResponse response){
		QueryFilter queryFilter = new QueryFilter(request);
		//queryFilter.getPagingBean().setPageSize(50);
		List<SysImages> list = sysImagesService.getAll(queryFilter);
		request.setAttribute("sysImagesList", list);
		request.setAttribute("pageBean", queryFilter.getPagingBean());
		return "system/image_upload";
	}
	@RequestMapping("/json_get_sys_image")
	public String get(HttpServletRequest request,HttpServletResponse response){
		String imgId = request.getParameter("imgId");
		if(StringUtils.isNotEmpty(imgId)){
			SysImages sysImages = sysImagesService.get(new Long(imgId));
			JSONSerializer json = new JSONSerializer();
			request.setAttribute("jsonString", json.serialize(sysImages));
		}
		return "jsonString";
	}
	
}